const App = {
    mixins: [Save],//配置文件，路径/utils/mixins.js
    data() {
        return {
            photo,
            dish_category: [], // 存储树形结构的菜品类别
            merchant:[],
            dataForm:{
                Food_Information:'',
            }
        };
    },
    mounted() {
        this.getCategory();
    },
    methods: {
        getCategory() {
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/generalBusiness/generalQueryByTableName`,
                type: "POST",
                data: {
                    Data: 'merchant_business_mapping_blue_plate',
                    Condition: "Row_Status='0'", // 只查询有效店铺
                },
                success: (data) => {//
                    // 构建树形结构数据
                    data.forEach(item =>{
                        item.id = item.Merchant_Mapping_Blue_Plate_SerialNumber;
                        item.name = item.Merchant_Alias
                    })
                    $.ajax({
                        headers: requestHeaders(),
                        url: `${mh}/generalBusiness/generalQueryBySQLSerialNumber`,
                        method: "post",
                        data: {
                            SQLSerialNumber: 'f_merchant_business_scope',
                            Condition: '',
                            ExtensionCondition: window.btoa(unescape(encodeURIComponent("AND (merchant_category.Parent_SerialNumber ='MC0000000000011' OR merchant_category.Parent_SerialNumber ='MC0000000000013')"))),
                        },
                        success: (data1) => {
                            data1.forEach(item=>{
                                item.id = item.Merchant_Business_Scope_SerialNumber;
                                item.name = item.Merchant_Category;
                                item.children = data.filter(i=> i.Merchant_Business_Scope_SerialNumber == item.Merchant_Business_Scope_SerialNumber);
                            })
                            data1 = data1.filter(i=>i.children.length > 0);
                            $.ajax({
                                headers: requestHeaders(),
                                url: `${mh}/generalBusiness/generalQueryByTableName`,
                                type: "POST",
                                data: {
                                    Data: 'merchant',
                                    Condition: "Row_Status='0'", // 只查询有效店铺
                                },
                                success: (data2) => {//
                                    data2.forEach(item=>{
                                        item.id = item.Merchant_SerialNumber;
                                        item.name = item.Merchant_Name;
                                        item.children = data1.filter(i=> i.Merchant_SerialNumber == item.Merchant_SerialNumber);
                                    })
                                    data2 = data2.filter(i=>i.children.length > 0);
                                    this.merchant = data2;
                                },
                                complete: (XMLHttpRequest) => {
                                    requestPretreatment(XMLHttpRequest);
                                },
                                dataType: "json",
                            });
                        },
                        complete: (XMLHttpRequest) => {
                            requestPretreatment(XMLHttpRequest);
                        },
                    })
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest);
                },
                dataType: "json",
            });
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/generalBusiness/generalQueryForObtainingTrees`,
                type: "GET",
                data: {
                    TableName:'dish_category',
                    NodeCode:''
                },
                success: (data) => {
                    this.dish_category = data; // 直接使用 this
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest)
                },
                dataType: "json",
            });
        },
    },
};
const { createApp, ref } = Vue;
const app = createApp(App);
app.use(ElementPlus, { locale: zhCn });
//这种方式是引入全部图标，无需单个引入
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}
app.component('yl-upload', ylUpload);
app.component('yl-cascader', ylCascader)
app.component('yl-text-editor', ylTextEditor);
app.component('yl-select', ylSelect)
const ElMessage = ElementPlus.ElMessage;
app.mount("#app");
